{include file="public/header" /}

<div class="page">
  <form id="adv_form" enctype="multipart/form-data" method="post" name="advForm">
    <table class="ds-default-table">
      <tbody>
        <tr class="noborder">
          <td class="required w120"><label class="validation" for="name">{$Think.lang.name}:</label></td>
          <td class="vatop rowform"><input type="text" name="name" id="name" class="txt" value="{$adv.adv_title|default=''}"></td>
          <td class="vatop tips">商品名称，最长14个汉字，1个汉字相当于2个字符</td>
        </tr>
        <tr class="noborder" id="adv_code">
            <td class="required"><label  class="validation" for="file_adv_code">{$Think.lang.adv_img_upload}:</label></td>
            <td class="vatop rowform">
                {notempty name="$adv.coverImg_1"}
                <span class="type-file-show"><img class="show_image" src="{$Think.ADMIN_SITE_ROOT}/images/preview.png">
                    <div class="type-file-preview"><img src="{$adv.coverImg_1|default=''}"></div>
                </span>
                {/notempty}
                <span class="type-file-box">
                    <input type='text' name='textfield' id='textfield1' class='type-file-text' />
                    <input type='button' name='button' id='button1' value='' class='type-file-button' />
                    <input name="coverImg" id="file_adv_code" type="file" class="type-file-file" id="site_logo" size="30" hidefocus="true">
                </span>
            </td>
          <td class="vatop tips">{$Think.lang.adv_edit_support}gif,jpg,jpeg,png 图片规则：图片尺寸最大300像素*300像素；</td>
        </tr>
        <tr class="noborder">
            <td class="required"><label class="validation">{$Think.lang.price_type}:</label></td>
            <td class="vatop rowform">
                <select name="priceType" id="priceType">
                    <option value='1' >一口价</option>
                    <option value='2' >价格区间</option>
                    <option value='3' >显示折扣价</option>
                </select>
            </td>
            <td class="vatop tips">1：一口价（只需要传入价格，价格2不传） 2：价格区间（价格字段为左边界，价格2字段为右边界，价格和价格2必传） 3：显示折扣价（价格字段为原价，价格2字段为现价， 价格和价格2必传）</td>
        </tr>
        <tr class="noborder">
            <td class="required w120"><label class="validation" for="name">{$Think.lang.price}:</label></td>
            <td class="vatop rowform"><input type="text" name="price" id="price" class="txt" value="{$adv.adv_title|default=''}"></td>
            <td class="vatop tips">数字，最多保留两位小数，单位元</td>
        </tr>
        <tr class="noborder">
            <td class="required w120"><label class="validation" for="name">{$Think.lang.price1}:</label></td>
            <td class="vatop rowform"><input type="text" name="price2" id="price2" class="txt" value="{$adv.adv_title|default=''}"></td>
            <td class="vatop tips">数字，最多保留两位小数，单位元</td>
        </tr>
        <tr class="noborder">
            <td class="required w120"><label class="validation" for="name">商品id:</label></td>
            <td class="vatop rowform"><input type="text" name="goods_id" id="goods_id" class="txt" value="{$adv.goods_id|default=''}"></td>
            <td class="vatop tips">当前商城已经存在的商品id</td>
        </tr>
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>{$Think.lang.ds_submit}</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<link href="{$Think.PLUGINS_SITE_ROOT}/colorpicker/evol.colorpicker.css" rel="stylesheet" type="text/css">
<script src="{$Think.PLUGINS_SITE_ROOT}/colorpicker/evol.colorpicker.min.js"></script>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-file-upload/jquery.fileupload.js"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/jquery.ajaxContent.pack.js"></script>
<script type="text/javascript">
$(function(){
    $('#startTime').datetimepicker({dateFormat: 'yy-mm-dd'});
    $('#endTime').datetimepicker({dateFormat: 'yy-mm-dd'});

$("#file_adv_code").change(function () {
            $("#textfield1").val($("#file_adv_code").val());
        });
});
$("#file_adv_code_1").change(function () {
    $("#textfield2").val($("#file_adv_code_1").val());
});
</script>

<script>
//按钮先执行验证再提交表单
$(function () {
    $("#submitBtn").click(function () {
        if ($("#adv_form").valid()) {
            $("#adv_form").submit();
        }
    });
});
//
$(document).ready(function () {

    $('#adv_form').validate({
        errorPlacement: function (error, element) {
            error.appendTo(element.parent().parent().find('td:last'));
        },
        rules: {
            adv_name : {
                required: true
            },
            adv_sort : {
                number:true,
                range:[0,255]
            }
        },
        messages: {
            adv_name : {
                required : '{$Think.lang.adv_can_not_null}'
            },
            adv_sort : {
                number:'{$Think.lang.ds_sort_number}',
                range:'{$Think.lang.ds_range_0_255}'
            }
        }
    });
});
</script>